package com.example.j280_webproject.day039.servlet;

import com.example.j280_webproject.day039.service.SelectStudentListService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/selectStudentList")
public class SelectStudentListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String studentName = req.getParameter("studentName");
        String card = req.getParameter("card");
        SelectStudentListService selectStudentListService = new SelectStudentListService();
        List<com.example.j280_webproject.day039.pojo.Student038> list = selectStudentListService.selectStudentList(studentName, card);
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter writer = resp.getWriter();
        if(list==null){
            writer.print("系统繁忙请稍后再试！");
            return;
        }
        if(list.size() == 0) {
            writer.print("对不起，没有查询匹配的内容！");
            return;
        }
        writer.print("学生ID" + "   "  + "学生名称" + "   "  + "班级id" + "   "  + "身份证" + "<br/>");
        for (com.example.j280_webproject.day039.pojo.Student038 myStudent : list) {
            writer.print(myStudent.id+"  "+myStudent.studentName+"  "+myStudent.calss_id +"  "+myStudent.card +"<br/>");
        }
    }
}
